﻿using System;
using System.Collections.Generic;
using System.Net.Mail;
using System.Text;

namespace Sprout.Core.Dtos
{
    /// <summary>
    /// 邮件
    /// </summary>
    public class EmailDto
    {
        /// <summary>
        /// 发件人邮箱地址
        /// </summary>
        public MailAddress From { get; set; }

        /// <summary>
        /// 接收人邮件列表
        /// </summary>
        public List<MailAddress> ToList { get; set; }
        /// <summary>
        /// 设置抄送人邮箱列表
        /// </summary>
        public List<MailAddress> CCList { get; set; }

        /// <summary>
        /// 邮件标题
        /// </summary>
        public string Subject { get; set; }

        /// <summary>
        /// 邮件标题编码格式
        /// </summary>
        public Encoding SubjectEncoding { get; set; } = Encoding.UTF8;

        /// <summary>
        /// 邮件内容
        /// </summary>
        public string Body { get; set; }

        /// <summary>
        /// 邮件内容编码格式
        /// </summary>
        public Encoding BodyEncoding { get; set; } = Encoding.UTF8;
        /// <summary>
        /// 邮件正文是否是HTML格式
        /// </summary>
        public bool IsBodyHtml { get; set; } = false;

        /// <summary>
        /// 附件地址列表
        /// </summary>
        public List<string> AttachmentList { get; set; }

        /// <summary>
        /// 邮件优先级
        /// </summary>
        public MailPriority Priority { get; set; } = MailPriority.Normal;

        /// <summary>
        /// 发件人邮箱账户
        /// </summary>
        public string Account { get; set; }

        /// <summary>
        /// 发件人邮箱密码
        /// </summary>
        public string Password { get; set; }

        /// <summary>
        /// 邮箱服务器(smtp)
        /// </summary>
        public string SmtpHost { get; set; }

        /// <summary>
        /// 邮箱端口
        /// </summary>
        public int Port { get; set; } = 25;

        /// <summary>
        /// 是否安全发送
        /// </summary>
        public bool UseSsl { get; set; } = false;
    }

    public class MailAddress
    {
        /// <summary>
        /// 地址
        /// </summary>
        public string Address { get; set; }
        /// <summary>
        /// 显示名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 编码
        /// </summary>
        public Encoding Encoding { get; set; } = Encoding.UTF8;
    }
}
